home *** CD-ROM | disk | FTP | other *** search
- /* PostRexxDemo.rexx */
-
- OPTIONS FAILAT 100
- OPTIONS RESULTS
-
- /* some global definitions */
- HIGH = '1B'X || '[32m'
- INFO = '1B'X || '[33m'
- BOLD = '1B'X || '[1m'
- NORMAL = '1B'X || '[0m'
- CR = '0A'X
-
- /* post already running? */
- if ~show('P', 'POST.1') then do
- ADDRESS COMMAND 'RUN > NIL: POST:Post OPTFILE POST:envarc/POST.rexxdemo'
- ADDRESS COMMAND WaitForPort 'POST.1'
- end
-
- ADDRESS 'POST.1'
-
- SAY HIGH || BOLD || "Welcome to the world of post!" || NORMAL CR
- SAY "This is an introduction to the arexx-commands of post. Each command"
- SAY "is explained with a few words and introduced with a small example."
- SAY "The example-lines are " || HIGH || "highlighted " || NORMAL || "and after you read them and pressed"
- SAY "return they will be interpreted."
- CALL wait()
- SAY "If an error occurs and OPTIONS RESULTS is active, the special arexx"
- SAY "variable RC (return code) will be set and the error string will be"
- SAY "found in the variable POST.LASTERROR. If the given arguments have"
- SAY "the wrong type or there are too few arguments RC will be set to 20."
- SAY "Less severe errors will cause a warning (RC = 5)"
- SAY "NOTE: The commands are not case-sensitive, e.g. okmsg equals OKmSg."
- SAY ""
-
- SAY "The OKMSG command will display a given text in an AutoRequester:"
- CALL do_command('okmsg "this is a test"')
-
- SAY HIGH || "The window functions:" || NORMAL
- SAY "You can open/close the window with OPENWINDOW/CLOSEWINDOW, bring it"
- SAY "to front/back with WINDOWTOFRONT/WINDOWTOBACK, zip it with ZIPWINDOW"
- SAY "and activate it with ACTIVATEWINDOW."
- CALL wait()
- SAY "Furthermore you can move and size the window with"
- SAY "'CHANGEWINDOWBOX left top width height'"
- SAY "left and top are the coordinates of the upper-left corner of the window"
- SAY "and width and height are its dimensions. This function is save, but"
- SAY "wrong arguments may cause unexpected results."
- SAY "zip and changewindow demo:"
- CALL do_command ('zipwindow; okmsg "window zipped"' || CR ||,
- 'changewindowbox 50 50 150 150;Â okmsg "window changed"' || CR ||,
- 'zipwindow; okmsg "window re-zipped"')
- SAY "The window will be activated for 3 secs and then it will be closed."
- SAY "Some errors will be produced because you can do nothing with a closed"
- SAY "window but open it again:"
- CALL do_command('activatewindow; ADDRESS COMMAND Wait 3' || CR ||,
- 'closewindow; okmsg "now the window is gone"' || CR ||,
- 'closewindow; if RC > 0 THEN okmsg "close error: " POST.LASTERROR' || CR ||,
- 'windowtoback; if RC > 0 THEN okmsg "toback error: " POST.LASTERROR' || CR ||,
- 'zipwindow; if RC > 0 THEN okmsg "zip error: " POST.LASTERROR')
- SAY "The window is opened again and an error is produced because you can't"
- SAY "open it twice. Then it is sent to back and to front again:"
- CALL do_command('openwindow' || CR ||,
- 'openwindow; if RC > 0 THEN okmsg "open error: " POST.LASTERROR' || CR ||,
- 'windowtoback; okmsg "window is sent to back"; windowtofront')
-
- SAY HIGH || "The screen functions:" || NORMAL
- SAY "SCREENTOFRONT/SCREENTOBACK will bring the screen to front/back."
- SAY "NOTE: if Post is running on an public screen it is affected by these"
- SAY "commands, too. Maybe the result is not the one you expect!"
- CALL do_command('screentoback; ADDRESS COMMAND Wait 3; screentofront')
-
-
- SAY "The OPEN command will load a file and interpret it:"
- CALL do_command('open "POST:doc/post.ps"')
-
- SAY "Now we can go to the next page with the NEXTPAGE command. If it was"
- SAY "the last page the interpreter will return to the status 'Waiting'."
- SAY "If the page was not ready (that means the status of the interpreter"
- SAY "was not 'Paused'), the NEXTPAGE command would set the RC=5."
- CALL do_command('DO UNTIL rc == 0' || CR ||,
- ' if rc > 0 THEN okmsg POST.LASTERROR' || CR ||,
- ' nextpage' || CR ||,
- 'END')
-
- SAY "With the GOTOPAGE command you can display a specific page if the"
- SAY "file is EPSF:"
- CALL do_command('DO UNTIL rc == 0' || CR ||,
- ' if rc > 0 THEN okmsg POST.LASTERROR' || CR ||,
- ' gotopage 4' || CR ||,
- 'END')
-
- SAY HIGH || "The scroll functions:" || NORMAL
- SAY "UP / DOWN / LEFT / RIGHT will scroll up / down / left / right the given"
- SAY "value. If it is too high you will arrive at the corner. These functions"
- SAY "are safe (you can't scroll over the corners), but they do not inform you"
- SAY "wheter you reached the corner or not."
- SAY "Let's zip the window and change its dimensions:"
- CALL do_command('ZIPWINDOW; CHANGEWINDOWBOX 0 0 400 250')
- SAY "Now scrolling makes sense. First we produce an error, because 'a' is not"
- SAY "a correct argument to UP. Then we set up the commands for slow scrolling"
- SAY "down and right, and fast scrolling up and left"
- CALL do_command('UP a ; if rc > 0 THEN okmsg POST.LASTERROR' || CR ||,
- 'com.1 = DOWN 1; com.2 = UP 10; com.3 = RIGHT 1; com.4 = LEFT 10' || CR ||,
- 'UP 10000; LEFT 10000; /* make sure we start at the corners */')
- SAY "Now we can scroll a little bit. At last the window is unzipped again:"
- CALL do_command('DO i=1 TO 4' || CR ||,
- ' DO j = 1 to 600' || CR ||,
- ' com.i'|| CR ||,
- ' END' || CR ||,
- 'END' || CR ||,
- 'ZIPWINDOW')
-
- SAY HIGH || "The CLEAR command" || NORMAL
- SAY "will reset the interpreter:"
- CALL do_command('CLEAR')
-
- SAY HIGH || "The GETSTATUS command:" || NORMAL
- SAY "All unknown commands will be passed to the interpreter (NOTE: the"
- SAY "interpreter treads this string case sensitive, furthermore it must"
- SAY "not exceed 255 Bytes). The GETSTATUS command will set the variables"
- SAY "POST.ERRORNUM, POST.ERROR and POST.STATUS. POST.ERRORNUM contains"
- SAY "the error number the interpreter returned, POST.ERROR contains the"
- SAY "corresponding error string and POST.STATUS contains one of the"
- SAY "following: ineractive, arexx, paused, startup, running or waiting."
- CALL wait()
- CALL do_command('NOCOMMAND')
- CALL do_command('GETSTATUS' || CR ||,
- 'okmsg ERRNUM POST.ERRORNUM' || CR ||,
- 'okmsg ERROR POST.ERROR' || CR ||,
- 'okmsg STATUS POST.STATUS')
-
- SAY "The last command is QUIT, which will ... "
- CALL do_command('QUIT')
- EXIT
-
- do_command:
- PARSE ARG LINE
-
- SAY HIGH || LINE || NORMAL
- CALL wait
- INTERPRET LINE
- RETURN
-
- wait:
- SAY "press" || INFO || " RETURN " || NORMAL || "to continue!"
- PULL dummy
- RETURN